

package tomkitty;

import java.util.*;
import java.io.*;

public class TkConfiguration extends Properties implements Configuration {

  public TkConfiguration() {
    super();
  }

  public TkConfiguration(Configuration defaults) {
    super((Properties) defaults);
  }

  public Enumeration<?> getKeys() {
    return super.propertyNames();
  }

  public TkConfiguration set(String key, String value) {
    super.setProperty(key, value);
    return this;
  }

  public String get(String key) {
    return super.getProperty(key);
  }

  public void loadConfFromXML(String file) {
    FileInputStream xml = null;
    try {
      xml = new FileInputStream(file);
      loadFromXML(xml);
      xml.close();
    } catch (Exception e) {
      Debug.e("can't load config: " + e.getMessage());
      try {
        xml.close();
      } catch (Exception o_e) {
      }
    }
  }

  public void storeConfToXML(String file) {
    FileOutputStream xml = null;
    try {
      xml = new FileOutputStream(file);
      storeToXML(xml, "Written by "+Main.name+"/"+Main.version);
      xml.close();
    } catch (Exception e) {
      try {
        xml.close();
      } catch (Exception ee) {
        ee.printStackTrace();
      }
    }
  }

}
